<!-- 报告审核弹窗 -->
<template>
  <a-modal
    :maskClosable="false"
    :title="title"
    :width="1350"
    :bodyStyle="{
      padding: '0 24px'
    }"
    :visible="visible"
    @cancel="handleCancel"
    cancelText="关闭">

    <ErpReportAuditForm ref="reportAuditModalForm" :disabled="true" normal>
    </ErpReportAuditForm>
    <a-row type="flex" justify="center">
      <a-col :span="24">
        <!-- 流程历史跟踪 -->
        <common-flow-list v-if="model.bpmStatus !== '1'" :formData="formData"></common-flow-list>
      </a-col>
    </a-row>
    <div slot="footer" style="padding-bottom: 30px; background: #ffffff;">
      <a-button @click.stop="handleCancel">关闭</a-button>
    </div>
  </a-modal>
</template>

<script>

  import ErpReportAuditForm from '@/views/erp/omc/reportaudit/modules/ErpReportAuditForm.vue'
  import { getAction } from '@/api/manage'
  import CommonFlowList from '@/views/components/CommonFlowList.vue' // 审批历史流程列表组件
  export default {
    name: 'ErpOmcTaskDistributionModal',
    components: {
      ErpReportAuditForm,
      CommonFlowList
    },
    props: {
      title: {
        type: String,
        default: '报告审核单详情',
        required: false
      }
    },
    data () {
      return {
        width: 1024,
        visible: false,
        mounted: false,
        buttonDisable: false, // 2022-12-05 新增保存按钮重复点击限制
        disableSubmit: false,
        reportAuditModalForm:null,
        url: {
          getBizHisProcessNodeInfo: '/api/erpmng/act/process/extActProcessNode/getBizHisProcessNodeInfo'
        },
        formData: {
          isShowDeptLeader: ''
        },
        model: {},
        // 代码生成后需手动设置流程编码
        flowCode: 'onl_erp_report_audit'
      }
    },
    mounted() {
      this.mounted = true
    },
    computed: {
      dialogTrigger() {
        return [this.taskId, this.mounted]
      }
    },
    watch: {
      dialogTrigger() {
        if (!this.mounted) {
          return
        }

        if (this.taskId && this.type === 'assign') {
          this.buttonDisable = false
          this.visible = true
        }
      }
    },
    methods: {
      add () {
        this.buttonDisable = false
        this.visible = true
        this.$nextTick(() => {
          this.$refs.reportAuditModalForm.add();
        })
      },
      edit (record) {
        this.buttonDisable = false
        this.visible = true
        this.model = record
        let params = { flowCode: this.flowCode, dataId: record.id };// 查询条件
        this.viewTrack(params)
        this.$nextTick(() => {
          this.$refs.reportAuditModalForm.edit(record)
        });
      },
      // 获取流程
      viewTrack (params) {
      getAction(this.url.getBizHisProcessNodeInfo, params).then((res) => {
        if (res.success) {
          var data = {
            dataId: res.result.dataId,
            procInsId: res.result.procInsId,
            tableName: res.result.tableName,
            vars: res.result.records
          }
          this.formData = data;
        }
      })
    },
      close () {
        this.visible = false;
      },
      submitCallback() {
        this.$emit('ok');
        this.visible = false;
        this.taskId && this.$bus.$emit('update-id-tab')
      },
      unButtonDisable () {
        this.buttonDisable = false
      },
      handleOk () {
        // this.buttonDisable = true
        this.$refs.reportAuditModalForm.submitForm();
      },
      handleCancel () {
        this.close()
      }
    }
  }
</script>

<style lang="less" scoped>
/** Button按钮间距 */
  .ant-btn {
    margin-left: 30px;
    margin-bottom: 30px;
    float: right;
  }
  .drawer-footer{
    position: absolute;
    bottom: -8px;
    width: 100%;
    border-top: 1px solid #e8e8e8;
    padding: 10px 16px;
    text-align: right;
    left: 0;
    background: #fff;
    border-radius: 0 0 2px 2px;
    z-index:9999999
  }
</style>
